#ifndef PARSEBAT_H_
#define PARSEBAT_H_

#define BAT_DESCRIPTOR_MAX 1024
#define BAT_TRANSPORT_MAX 128

typedef struct TS_BAT_Section
{
    unsigned transport_stream_id          :16;
    unsigned original_network_id          :16;
    unsigned reserved_future_use          :4;
    unsigned transport_descriptors_length :12;

    unsigned char descriptor[BAT_DESCRIPTOR_MAX];           

}TS_BAT_Section;

typedef struct TS_BAT
{
    unsigned table_id                     :8;
    unsigned section_syntax_indicator     :1;
    unsigned reserved_future_use1          :1;
    unsigned reserved1                     :2;
    unsigned section_length               :12;
    unsigned bouquet_id                   :16;
    unsigned reserved2                     :2;
    unsigned version_number               :5;
    unsigned current_next_indicator       :1;
    unsigned section_number               :8;
    unsigned last_section_number          :8;
    unsigned reserved_future_use2          :4;
    unsigned bouquet_descriptors_length   :12;

    unsigned char descriptor[BAT_DESCRIPTOR_MAX];

    unsigned reserved_future_use3          :4;
    unsigned transport_stream_loop_length :12;

    TS_BAT_Section BAT_Section [BAT_TRANSPORT_MAX]; 

    unsigned CRC_32                       :32;

    struct TS_BAT *next; 
	struct TS_BAT *Previous;
}TS_BAT;


TS_BAT *TS_PackageBatPoint;
TS_BAT *BatPoint;

#endif